package com.jboost.modules.app.service.strategry.fhd;


import com.alibaba.fastjson.JSONObject;
import com.jboost.common.util.JSONUtil;
import com.jboost.modules.app.constant.BaseResult;
import com.jboost.modules.system.entity.FhdBom;
import com.jboost.modules.system.entity.FhdProductDz;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service(value = "FhdProductQuery")
@Slf4j
public class FhdProductQuery extends AbstractFhdPoduct<JSONObject, Boolean> {
    public String getAppId() {
        return "648df446b1562f0008efff79";
    }

    public String getFormId() {
        return "652b6fed44ed4526039b8c0a";
    }

    @Async
    @Scheduled(cron = "0 0/59 * * * ?")
    public BaseResult<Boolean> invokeStrategy() throws Exception {
        sync(new FhdProductDz());
        return BaseResult.success();
    }
    @Override
    public BaseResult<Boolean> invokeStrategy(JSONObject jsonObject) throws Exception {
        String id = jsonObject.getJSONObject("data").getString("id");
        FhdProductDz fhdProductDz = JSONUtil.fromJson(jsonObject.getJSONObject("data").toJSONString(), FhdProductDz.class);
        fhdProductDz.setId(id);
        baseMapper.insert(fhdProductDz);

        return BaseResult.success();
    }
}
